import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login/index.vue'
import Index from '../views/index/index.vue'
import Doctor from '../views/doctor/index.vue'
import scientificPart from '../views/scientificPart/index.vue'
import {
	getStorage,
} from '@/utils/auth'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

const routes = [

	// 测试
	{
		path: '/login',
		name: 'login',
		component: Login
	},
	{
		path: '/',
		name: 'readList',
		redirect: 'readList',
		component: Index,
		children: [{
			path: 'mine',
			component: () =>
				import( /* webpackChunkName: "Mine" */ '../views/mine/index.vue'),
			name: 'Mine'
		}, {
			path: 'readList',
			component: () =>
				import( /* webpackChunkName: "readList" */ '../views/readList/index.vue'),
			name: 'readList'
		}, ]
	}, {
		path: '/consultation',
		component: () =>
			import( /* webpackChunkName: "consultation" */ '../views/consultation/index.vue'),
		name: 'consultation'
	}, {
		path: '/covidList',
		component: () =>
			import( /* webpackChunkName: "covidList" */ '../views/covidList/index.vue'),
		name: 'covidList',
		meta: {
			keepAlive: true
		}
	}, {
		path: '/noduleList',
		component: () =>
			import( /* webpackChunkName: "noduleList" */ '../views/noduleList/index.vue'),
		name: 'noduleList',
		meta: {
			keepAlive: true
		}
	},
	{
		path: '/detailList',
		component: () =>
			import( /* webpackChunkName: "detailList" */ '../views/detailList/index.vue'),
		name: 'detailList'
	},
	{
		path: '/lungList',
		component: () =>
			import( /* webpackChunkName: "lungList" */ '../views/lungList/index.vue'),
		name: 'lungList'
	},
	{
		path: '/detail',
		component: () =>
			import( /* webpackChunkName: "detail" */ '../views/detail/index.vue'),
		name: 'detail'
	},
	{
		path: '/lungDetail',
		component: () =>
			import( /* webpackChunkName: "lungDetail" */ '../views/lungDetail/index.vue'),
		name: 'lungDetail'
	},
	{
		path: '/reportDetail',
		component: () =>
			import( /* webpackChunkName: "reportDetail" */ '../views/reportDetail/index.vue'),
		name: 'reportDetail'
	},
	{
		path: '/lungReport',
		component: () =>
			import( /* webpackChunkName: "lungReport" */ '../views/lungReport/index.vue'),
		name: 'lungReport'
	},
	{
		path: '/password',
		component: () =>
			import( /* webpackChunkName: "password" */ '../views/password/index.vue'),
		name: 'password'
	},
	{
		path: '/share',
		component: () =>
			import( /* webpackChunkName: "share" */ '../views/share/index.vue'),
		name: 'share'
	},
	{
		path: '/drList',
		component: () =>
			import( /* webpackChunkName: "drList" */ '../views/drList/index.vue'),
		name: 'drList'
	},
	{
		path: '/drDetail',
		component: () =>
			import( /* webpackChunkName: "drDetail" */ '../views/drDetail/index.vue'),
		name: 'drDetail'
	},
	{
		path: '/drReport',
		component: () =>
			import( /* webpackChunkName: "drReport" */ '../views/drReport/index.vue'),
		name: 'drReport'
	},
	{
		path: '/person',
		component: () =>
			import( /* webpackChunkName: "person" */ '../views/person/index.vue'),
		name: 'person'
	},
	{
		path: '/upload',
		component: () =>
			import( /* webpackChunkName: "upload" */ '../views/upload/index.vue'),
		name: 'upload'
	},
	{
		path: '/feedBack',
		component: () =>
			import( /* webpackChunkName: "feedBack" */ '../views/feedBack/index.vue'),
		name: 'feedBack'
	},
	{
		path: '/doctor',
		component: () =>
			import( /* webpackChunkName: "doctor" */ '../views/feedBack/index.vue'),
		name: 'doctor'
	}, {
		path: '/doctorList',
		component: () =>
			import( /* webpackChunkName: "doctorList" */ '../views/doctorList/index.vue'),
		name: 'doctorList'
	}, {
		path: '/doctorDetail',
		component: () =>
			import( /* webpackChunkName: "doctorDetail" */ '../views/doctorDetail/index.vue'),
		name: 'doctorDetail'
	}, {
		path: '/applyRead',
		component: () =>
			import( /* webpackChunkName: "applyRead" */ '../views/applyRead/index.vue'),
		name: 'applyRead'
	}, {
		path: '/doctorReport',
		component: () =>
			import( /* webpackChunkName: "doctorReport" */ '../views/doctorReport/index.vue'),
		name: 'doctorReport'
	}, {
		path: '/imgDetail',
		component: () =>
			import( /* webpackChunkName: "imgDetail" */ '../views/imgDetail/index.vue'),
		name: 'imgDetail'
	}, {
		path: '/evaluate',
		component: () =>
			import( /* webpackChunkName: "evaluate" */ '../views/evaluate/index.vue'),
		name: 'evaluate'
	}, {
		path: '/demoList',
		component: () =>
			import( /* webpackChunkName: "demoList" */ '../views/demoList/index.vue'),
		name: 'demoList'
	}, {
		path: '/demoImg',
		component: () =>
			import( /* webpackChunkName: "demoImg" */ '../views/demoImg/index.vue'),
		name: 'demoImg'
	}
]

const doctorRoutes = [{
		path: '/login',
		name: 'login',
		component: Login
	}, {
		path: '/',
		name: 'dindex',
		redirect: 'dindex',
		component: Doctor,
		children: [{
			path: 'dindex',
			component: () =>
				import( /* webpackChunkName: "dindex" */ '../views/dindex/index.vue'),
			name: 'dindex'
		}, {
			path: 'dMine',
			component: () =>
				import( /* webpackChunkName: "dMine" */ '../views/dMine/index.vue'),
			name: 'dMine'
		}]
	}, {
		path: '/checkList',
		component: () =>
			import( /* webpackChunkName: "checkList" */ '../views/checkList/index.vue'),
		name: 'checkList'
	}, {
		path: '/patientProfile',
		component: () =>
			import( /* webpackChunkName: "patientProfile" */ '../views/patientProfile/index.vue'),
		name: 'patientProfile'
	}, {
		path: '/doctorAdvice',
		component: () =>
			import( /* webpackChunkName: "doctorAdvice" */ '../views/doctorAdvice/index.vue'),
		name: 'doctorAdvice'
	}, {
		path: '/doctorImgDetail',
		component: () =>
			import( /* webpackChunkName: "doctorImgDetail" */ '../views/doctorImgDetail/index.vue'),
		name: 'doctorImgDetail'
	}, {
		path: '/hospital',
		component: () =>
			import( /* webpackChunkName: "hospital" */ '../views/hospital/index.vue'),
		name: 'hospital'
	}, {
		path: '/keepAsk',
		component: () =>
			import( /* webpackChunkName: "keepAsk" */ '../views/keepAsk/index.vue'),
		name: 'keepAsk'
	}, {
		path: '/doctorAuthentication',
		component: () =>
			import( /* webpackChunkName: "doctorAuthentication" */ '../views/doctorAuthentication/index.vue'),
		name: 'doctorAuthentication'
	}, {
		path: '/Training',
		component: () =>
			import( /* webpackChunkName: "Training" */ '../views/Training/index.vue'),
		name: 'Training'
	}, {
		path: '/doctorPerson',
		component: () =>
			import( /* webpackChunkName: "doctorPerson" */ '../views/doctorPerson/index.vue'),
		name: 'doctorPerson'
	},
	{
		path: '/classDetail',
		component: () =>
			import( /* webpackChunkName: "classDetail" */ '../views/classDetail/index.vue'),
		name: 'classDetail'
	},
	{
		path: '/classMore',
		component: () =>
			import( /* webpackChunkName: "classMore" */ '../views/classMore/index.vue'),
		name: 'classMore',
	}, {
		path: '/signClass',
		component: () =>
			import( /* webpackChunkName: "signClass" */ '../views/signClass/index.vue'),
		name: 'signClass',
	}, {
		path: '/aiTest',
		component: () =>
			import( /* webpackChunkName: "aiTest" */ '../views/aiTest/index.vue'),
		name: 'aiTest',
	}, {
		path: '/testDetail',
		component: () =>
			import( /* webpackChunkName: "testDetail" */ '../views/testDetail/index.vue'),
		name: 'testDetail',
	},
	{
		path: '/feedBack',
		component: () =>
			import( /* webpackChunkName: "feedBack" */ '../views/feedBack/index.vue'),
		name: 'feedBack'
	}, {
		path: '/demoList',
		component: () =>
			import( /* webpackChunkName: "demoList" */ '../views/demoList/index.vue'),
		name: 'demoList'
	}, {
		path: '/demoImg',
		component: () =>
			import( /* webpackChunkName: "demoImg" */ '../views/demoImg/index.vue'),
		name: 'demoImg'
	}, {
		path: '/reportDetail',
		component: () =>
			import( /* webpackChunkName: "reportDetail" */ '../views/reportDetail/index.vue'),
		name: 'reportDetail'
	},
	{
		path: '/lungReport',
		component: () =>
			import( /* webpackChunkName: "lungReport" */ '../views/lungReport/index.vue'),
		name: 'lungReport'
	}, {
		path: '/doctorPassword',
		component: () =>
			import( /* webpackChunkName: "doctorPassword" */ '../views/doctorPassword/index.vue'),
		name: 'doctorPassword'
	}, {
		path: '/project',
		component: () =>
			import( /* webpackChunkName: "project" */ '../views/project/index.vue'),
		name: 'project'
	}, {
		path: '/cooperation',
		component: () =>
			import( /* webpackChunkName: "cooperation" */ '../views/cooperation/index.vue'),
		name: 'cooperation'
	}, {
		path: '/release',
		component: () =>
			import( /* webpackChunkName: "cooperation_release" */ '../views/cooperation/release.vue'),
		name: 'release'
	}, {
		path: '/cooperation_accept',
		component: () =>
			import( /* webpackChunkName: "cooperation_accept" */ '../views/cooperation/accept.vue'),
		name: 'cooperation_accept'
	}, {
		path: '/cooperation_cooperate',
		component: () =>
			import( /* webpackChunkName: "cooperation_cooperate" */ '../views/cooperation/cooperate.vue'),
		name: 'cooperation_cooperate'
	}, {
		path: '/cooperation_detail',
		component: () =>
			import( /* webpackChunkName: "cooperation_detail" */ '../views/cooperation/detail.vue'),
		name: 'cooperation_detail'
	}, {
		path: '/AIPartTime',
		component: () =>
			import( /* webpackChunkName: "AIPartTime" */ '../views/AIPartTime/index.vue'),
		name: 'AIPartTime'
	}, {
		path: '/AIPartTime_detail',
		component: () =>
			import( /* webpackChunkName: "AIPartTime_detail" */ '../views/AIPartTime/detail.vue'),
		name: 'AIPartTime_detail'
	}, {
		path: '/AIPartTime_contact',
		component: () =>
			import( /* webpackChunkName: "AIPartTime_contact" */ '../views/AIPartTime/contact.vue'),
		name: 'AIPartTime_contact'
	}, {
		path: '/AIPartTime_myPartTime',
		component: () =>
			import( /* webpackChunkName: "AIPartTime_myPartTime" */ '../views/AIPartTime/myPartTime.vue'),
		name: 'AIPartTime_myPartTime'
	}, {
		path: '/AIPartTime_accept',
		component: () =>
			import( /* webpackChunkName: "AIPartTime_accept" */ '../views/AIPartTime/accept.vue'),
		name: 'AIPartTime_accept'
	}, {
		path: '/AIPartTime_submit',
		component: () =>
			import( /* webpackChunkName: "AIPartTime_submit" */ '../views/AIPartTime/submit.vue'),
		name: 'AIPartTime_submit'
	}, {

		path: '/sindex',
		name: 'sindex',
		redirect: 'sindex',
		component: scientificPart,
		meta: {
			title: '首页'
		},
		children: [{
			path: '/sindex',
			component: () =>
				import( /* webpackChunkName: "dindex" */ '../views/scientificPart/sindex/index.vue'),
			name: 'sindex',
			meta: {
				title: '首页'
			}
		}, {
			path: '/sMine',
			component: () =>
				import( /* webpackChunkName: "sMine" */ '../views/scientificPart/sMine/index.vue'),
			name: 'sMine',
			meta: {
				title: '我的'
			}
		}, {
			path: '/forum',
			component: () =>
				import( /* webpackChunkName: "forum" */ '../views/scientificPart/forum/index.vue'),
			name: 'forum',
			meta: {
				title: '交流'
			}
		}, {
			path: '/caseDetail',
			component: () =>
				import( /* webpackChunkName: "caseDetail" */ '../views/scientificPart/caseDetail/index.vue'),
			name: 'caseDetail',
			meta: {
				title: '案例详情'
			}
		}, {
			path: '/medicalImage',
			component: () =>
				import( /* webpackChunkName: "medicalImage" */ '../views/scientificPart/medicalImage/index.vue'),
			name: 'medicalImage',
			meta: {
				title: '影像资料'
			}
		}, {
			path: '/imageForum',
			component: () =>
				import( /* webpackChunkName: "imageForum" */ '../views/scientificPart/imageForum/index.vue'),
			name: 'imageForum',
			meta: {
				title: 'AI影像'
			}
		}, {
			path: '/imgForumDetail',
			component: () =>
				import( /* webpackChunkName: "imgForumDetail" */ '../views/scientificPart/imgForumDetail/index.vue'),
			name: 'imgForumDetail',
			meta: {
				title: 'AI影像交流'
			}
		}, {
			path: '/biologicalForum',
			component: () =>
				import( /* webpackChunkName: "biologicalForum" */ '../views/scientificPart/biologicalForum/index.vue'),
			name: 'biologicalForum',
			meta: {
				title: 'AI生命组学'
			}
		}, {
			path: '/bioForumDetail',
			component: () =>
				import( /* webpackChunkName: "bioForumDetail" */ '../views/scientificPart/bioForumDetail/index.vue'),
			name: 'bioForumDetail',
			meta: {
				title: 'AI生命组学交流'
			}
		}, {
			path: '/sofewareForum',
			component: () =>
				import( /* webpackChunkName: "sofewareForum" */ '../views/scientificPart/sofewareForum/index.vue'),
			name: 'sofewareForum',
			meta: {
				title: 'AI软件与架构交流'
			}
		}, {
			path: '/sofeForumDetail',
			component: () =>
				import( /* webpackChunkName: "sofeForumDetail" */ '../views/scientificPart/sofeForumDetail/index.vue'),
			name: 'sofeForumDetail',
			meta: {
				title: 'AI软件与架构交流'
			}
		}]
	},
]


// const scientific = [{
//     path: '/login',
//     name: 'login',
//     component: Login
//   }, {
//     path: '/',
//     name: 'sindex',
//     redirect: 'sindex',
//     component: scientificPart,
//     meta: {
//       title: '首页'
//     },
//     children: [{
//       path: 'sindex',
//       component: () =>
//         import( /* webpackChunkName: "dindex" */ '../views/scientificPart/sindex/index.vue'),
//       name: 'sindex',
//       meta: {
//         title: '首页'
//       }
//     }, {
//       path: 'sMine',
//       component: () =>
//         import( /* webpackChunkName: "dMine" */ '../views/scientificPart/sMine/index.vue'),
//       name: 'sMine',
//       meta: {
//         title: '我的'
//       }
//     }, {
//       path: 'forum',
//       component: () =>
//         import( /* webpackChunkName: "forum" */ '../views/scientificPart/forum/index.vue'),
//       name: 'forum',
//       meta: {
//         title: '交流'
//       }
//     }, {
//       path: 'caseDetail',
//       component: () =>
//         import( /* webpackChunkName: "caseDetail" */ '../views/scientificPart/caseDetail/index.vue'),
//       name: 'caseDetail',
//       meta: {
//         title: '案例详情'
//       }
//     }, {
//       path: 'medicalImage',
//       component: () =>
//         import( /* webpackChunkName: "medicalImage" */ '../views/scientificPart/medicalImage/index.vue'),
//       name: 'medicalImage',
//       meta: {
//         title: '影像资料'
//       }
//     }, {
//       path: 'imageForum',
//       component: () =>
//         import( /* webpackChunkName: "imageForum" */ '../views/scientificPart/imageForum/index.vue'),
//       name: 'imageForum',
//       meta: {
//         title: 'AI影像'
//       }
//     }, {
//       path: 'biologicalForum',
//       component: () =>
//         import( /* webpackChunkName: "biologicalForum" */ '../views/scientificPart/biologicalForum/index.vue'),
//       name: 'biologicalForum',
//       meta: {
//         title: 'AI生命组学'
//       }
//     }, {
//       path: 'sofeForumDetail',
//       component: () =>
//         import( /* webpackChunkName: "sofeForumDetail" */ '../views/scientificPart/sofeForumDetail/index.vue'),
//       name: 'sofeForumDetail',
//       meta: {
//         title: 'AI软件与架构'
//       }
//     }]
//   },

// ]



const doctorToken = getStorage("doctorToken");
const router = new VueRouter({

	mode: 'hash',
	base: process.env.NODE_ENV === "production" ? "/wx/" : "/",
	// routes: doctorToken && doctorToken == 'doctor' ? doctorRoutes : doctorToken && doctorToken == 'scientific' ?
	//   scientific : routes
	routes: doctorToken && doctorToken == 'doctor' ? doctorRoutes : routes

})
export default router